package name.fowler.refactoring.simplestore.model;

import java.util.Collections;
import java.util.List;

public class Rental {
    private final List<Movie> movies;
    private final int daysRented;

    public Rental(List<Movie> movies, int daysRented) {
        this.movies = movies;
        this.daysRented = daysRented;
    }

    public double getAmount() {
        double result = 0;
        for (Movie movie : movies) {
            result += movie.getPriceCode().getAmount(daysRented);
        }
        return result;
    }

    public int getBonus() {
        int result = 0;
        for (Movie movie : movies) {
            result += movie.getPriceCode().getBonus(daysRented);
        }
        return result;
    }

    public int getDaysRented() {
        return daysRented;
    }

    public List<Movie> getMovies() {
        return Collections.unmodifiableList(movies);
    }
}

